package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.University;
import cn.wolfcode.crm.mapper.UniversityMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IUniversityService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UniversityServiceImpl implements IUniversityService {
    @Autowired
    private UniversityMapper universityMapper;
    @Override
    public void deleteByPrimaryKey(Long id) {
        universityMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(University entity) {
        universityMapper.insert(entity);
    }

    @Override
    public University selectByPrimaryKey(Long id) {

        return universityMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<University> selectAll() {
        return universityMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(University entity) {
        universityMapper.updateByPrimaryKey(entity);
    }

    public void changState(Long id) {
        universityMapper.changState(id);
    }

    @Override
    public PageResult query(QueryObject qo) {
        Integer total = universityMapper.query4Count(qo);
        if(total==0){
            return PageResult.PAGERESULT_EMPTY;
        }
        return new PageResult(total,universityMapper.query4List(qo));
    }
}
